﻿using System;
using Scommesse.Model;
using Scommesse.View;
using Scommesse.Persistence;

namespace Scommesse.Presenters
{
    class RicaricaBetCardPresenter : IRicaricaBetCardPresenter
    {
        private readonly BetCard _betCard;
        private readonly RicaricaBetCard _ricaricaForm;

        public RicaricaBetCardPresenter(BetCard betCard)
        {
            _betCard = betCard;
            _ricaricaForm = new RicaricaBetCard();
            _ricaricaForm.AddListener(this);
            _ricaricaForm.ShowDialog();
        }

        #region IRicaricaBetCardPresenter Members

        public void RicaricaCredito()
        {
            Random random = new Random();
            _betCard.RicaricaCredito((random.Next(9)+1)*5);
            DataSaver.SaveBetCardOnFile(_betCard);
            _ricaricaForm.Close();
        }
        #endregion
    }
}
